package com.erpanderp.wam.tm.model.service;

import org.hibernate.FlushMode;
import org.hibernate.Query;
import org.hibernate.Session;

import com.erpanderp.wam.tm.model.entity.Band;
import com.erpanderp.wam.util.HibernateUtil;

public class BandDAO {
	
	public Band getBandByBandId(Long bandId){
	 	Band band = new Band();
	 	try{
	 		Session session = HibernateUtil.getSessionFactory().getCurrentSession();
	 		session.beginTransaction();
	 		session.setFlushMode(FlushMode.AUTO);
	 		String queryString = "from Band b where b.bandId = :bandId";
	 		Query query = session.createQuery(queryString).setLong("bandId", bandId);
	 		query.setCacheable(false);
	 		band = (Band) query.uniqueResult();
	 		session.getTransaction().commit();
	 		return band;
	 	}catch (Exception e) {
	 		e.printStackTrace();
	 		return null;			
			}
	 	
	 }

}
